package com.sunxiansheng.config;

import com.sunxiansheng.trace.TraceIdFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * Description: 链路追踪配置
 * @Author sun
 * @Create 2024/8/2 12:05
 * @Version 1.0
 */
@Configuration
public class FilterConfig {

    @Resource
    private TraceIdFilter traceIdFilter;

    /**
     * 链路追踪过滤器配置
     * @return
     */
    public FilterRegistrationBean registrationBean() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(traceIdFilter);
        registrationBean.addUrlPatterns("/*");
        registrationBean.setName("traceIdFilter");
        registrationBean.setOrder(1);
        return registrationBean;
    }

}